module.exports = {


  friendlyName: 'Get patch progress for a single team',


  description: 'Returns patch progress for operating systems and critical software filtered to only be results for a team.',


  inputs: {
    teamApid: {
      description: 'The ID of the Team to filter by, or 0 to only include hosts with no team, or undefined to not filter by any team.',
      type: 'number',
    },
  },


  exits: {
    success: {
      outputType: {},
      description: 'Patch progress has been successfully filtered to a team'
    }
  },


  fn: async function ({teamApid}) {

    let osComplianceInfo = await sails.helpers.getComplianceInformation.with({teamApid, complianceType: 'operatingSystem' });
    let chromeComplianceInfo = await sails.helpers.getComplianceInformation.with({teamApid, complianceType: 'chrome' });
    let safariComplianceInfo = await sails.helpers.getComplianceInformation.with({teamApid, complianceType: 'safari' });
    let firefoxComplianceInfo = await sails.helpers.getComplianceInformation.with({teamApid, complianceType: 'firefox' });
    let microsoftOfficeComplianceInfo = await sails.helpers.getComplianceInformation.with({teamApid, complianceType: 'microsoftOffice' });
    let flashComplianceInfo = await sails.helpers.getComplianceInformation.with({teamApid, complianceType: 'flash' });

    let patchProgressForThisTeam = {
      operatingSystem: osComplianceInfo.patchProgress,
      chrome: chromeComplianceInfo.patchProgress,
      safari: safariComplianceInfo.patchProgress,
      firefox: firefoxComplianceInfo.patchProgress,
      microsoftOffice: microsoftOfficeComplianceInfo.patchProgress,
      flash: flashComplianceInfo.patchProgress,
    };

    let complaintVersionsInUse = {
      operatingSystem: osComplianceInfo.compliantVersionsInUse,
      chrome: chromeComplianceInfo.compliantVersionsInUse,
      safari: safariComplianceInfo.compliantVersionsInUse,
      firefox: firefoxComplianceInfo.compliantVersionsInUse,
      microsoftOffice: microsoftOfficeComplianceInfo.compliantVersionsInUse,
      flash: flashComplianceInfo.compliantVersionsInUse,
    };

    // All done.
    return {
      patchProgressForThisTeam,
      complaintVersionsInUse,
    };

  }


};
